<?php
/**
 * common repository file Created by PhpStorm.
 * User: yang
 * Date: 2020/07/02
 */

namespace Common\Repository;

use Common\Model\Visits;

class VisitsRepository extends BaseRepository
{
    public function baseModel()
    {
        return new Visits();
    }

    /**
     * 统计数量
     * @return mixed
     */
    public function extendCount()
    {
        //$week = date("Y-m-d", strtotime("-1 week"));//一周前时间
        //$data['week'] = Visits::where('created_at', '>', $week)->count();

        $month = date("Y-m-d", strtotime("-1 month"));//一月前时间
        $data['month'] = Visits::where('created_at', '>', $month)->count();
        $data['total'] = Visits::count();
        $data['ipMonth'] = Visits::where('created_at', '>', $month)->groupBy('ip')->get(['id'])->count();
        $data['ipTotal'] = Visits::groupBy('ip')->get(['id'])->count();

        return $data;
    }

}